package va.radiomaria.audio;

import java.io.File;
import java.io.Serializable;

public class Song implements Serializable {

	private static final long serialVersionUID = 1252275389553548150L;
	private String url;
	private String artist = "unknown";
	private String albumTitle = "unknown";
	private String songTitle = "unknown";
	private String genre = "unknown";
	
	public Song(String url) {
		url = url.replace('\\', '/');
		this.url = url;
	}

	public Song(String url, String localFilePath) {
		this(url, new File(localFilePath));
	}

	public Song(String url, File localFile) {
		url = url.replace('\\', '/');
		this.url = url;
		ID3Reader tagReader = new GeneralID3Reader(localFile);
		setArtist(tagReader.getArtist());
		setSongTitle(tagReader.getSongTitle());
		setAlbumTitle(tagReader.getAlbumTitle());
		setGenre(tagReader.getGenre().toLowerCase());
	}

	public String getArtist() {
		return artist;
	}

	public void setArtist(String artist) {
		this.artist = artist;
	}

	public String getAlbumTitle() {
		return albumTitle;
	}

	public void setAlbumTitle(String albumTitle) {
		this.albumTitle = albumTitle;
	}

	public String getSongTitle() {
		return songTitle;
	}

	public void setSongTitle(String songTitle) {
		this.songTitle = songTitle;
	}

	public String getGenre() {
		return genre;
	}

	public void setGenre(String genre) {
		this.genre = genre;
	}

	public String getUrl() {
		return url;
	}

	public String getStreamerIPAddress() {
		url.substring(7, url.lastIndexOf("/") + 1);
		return url.substring(7, url.lastIndexOf("/"));
	}

	public String getRadioMariaTag() {
		return this.getSongTitle() + ":" + this.getArtist() + ":" + this.getGenre() + ":" + this.getAlbumTitle();
	}
}
